Copyright: © Copyright 1995 - MediaDynamics Inc.


Contents
MediaDynamics VBVideo Custom Control

The VBVideo custom control was designed to assist Visual Basic programmers with the control and display of video and audio files.  VBVideo utilizes the MediaDynamics Media Control Library to handle all of the actual control functionality.

Custom Control Properties

Click on any of the following to receive more information.

Properties:

About 	x	FrameEnd	x

AutoLoad 	x	Height

AutoSize	x	HelpContextID

Backcolor	hWnd

ClipHeight	x	Index

ClipLeft	x	Left

ClipTop	x	Length	x

ClipType	x	MCIID	x

ClipWidth	x	MCIReturn	x

Command	x	MCIString	x

ControlBar 	x	Name

ControlBarData	x	Parent

ControlBarGraphic	x	PlayState	x

DataChanged	PlayUpon	x

DataField	Repeat	x

DataSource	ShowErrors	x

DragIcon	TabIndex

Dragmode	TabStop

Enabled	Tag

ErrorCount	x	TimerEnabled	x

ErrorNumber	x	TimerInterval	x

ErrorSeverity 	x	Top

FileName	x	Type	x

Frame 	x	Visible

FrameBeg	x	Width

x - VBVideo Custom Properties

Events:

Timer

PlayStateChange

CustomButtonClick

Other Topics:

Database Access (Bound Control)


Formats Supported

Video

Intel Indeo

Intel DVI

Microsoft Video1

Microsoft Run-length Encoded

MPEG

Apple QuickTime for Windows

Supermac Cinepak

Audio

Uncompressed Wave

Compressed ADPCM Wave


About

MediaDynamics Inc.

1032 West 67th Street

Downers Grove, Illinois  60516

Phone: (708) 968-7803

Fax: (708) 968-7407

VBVideo Custom Control Version 3.0

(C) 1993-95 MediaDynamics Inc.

All Rights Reserved


AutoLoad

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: False

The AutoLoad property determines when the VBVideo control will load the AV file.  A value of True will cause the control to load the AV file when the FileName property is set explicitly or through the use of database binding.

A value of False indicates that the control should not load the AV file until the Command property is set to 1.


AutoSize

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: True

When set to True, this property will cause the video display window to automatically adjust to the size of the video being played.

When set to False, this property will cause the video file to adjust to the size of the video display window.


ClipHeight

Usability: Edit/Runtime	Type:  Read/Write	Values:  Pixel Value

Example	See Also	Default: 0

The height of the video clipping region.

Note: All clipping measurements are in pixels.  See the video clipping description in the Media Control Library User Guide for additional information.


ClipLeft

Usability: Edit/Runtime	Type:  Read/Write	Values:  Pixel Value

Example	See Also	Default: 0

The left side of the clipping region.  (The X coordinate)

Note: All clipping measurements are in pixels.  See the video clipping description in the Media Control Library User Guide for additional information.


ClipTop

Usability: Edit/Runtime	Type:  Read/Write	Values:  Pixel Value

Example	See Also	Default: 0

The top side of the video clipping region.  (The Y coordinate)

Note: All clipping measurements are in pixels.  See the video clipping description in the Media Control Library User Guide for additional information.


ClipType

Usability: Edit/Runtime	Type:  Read/Write	Values:  0-4

Example	See Also	Default: 0

The type of video clipping to perform.  The valid types are listed below.

0:	Reset the image back to the original size - no clipping.

1:	Video clipped / video window resized - no scaling - video is cropped and aligned.

2:	Video clipped / video window size unchanged - scaling - "ZOOM".

3:	Video clipped / video window size unchanged - no scaling - "As Is".

4:	Video clipped / video window size unchanged - no scaling - centered.

Note: All clipping measurements are in pixels.  See the video clipping description in the Media Control Library User Guide for additional information.


ClipWidth

Usability: Edit/Runtime	Type:  Read/Write	Values:  Pixel Value

Example	See Also	Default: 0

The width of the video clipping region.

Note: All clipping measurements are in pixels.  See the video clipping description in the Media Control Library User Guide for additional information.


Command

Usability: Runtime	Type:  Write	Values:  1 - 6

Example	See Also	Default: None

Allows control of the Audio & Video.

0:	Close (if it is open)

1:	Open

2:	Play

3:	Pause

4:	Stop

5:	Rewind to beginning frame

6:	Rewind and restart playing


ControlBar

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: True

This property regulates the visibility of the Control Bar.  A value of True will make the Control Bar visible while a value of False hides the Control Bar.  The Control Bar will only display if an Audio/Video file is loaded.


ControlBarData

Usability: Edit/Runtime	Type:  Read/Write	Values:  FileName

Example	See Also	Default: None

The data file describing the custom Control Bar Graphic file.  This file must be created with the Custom Control Bar Builder utility program described in the Media Control Library manual.


ControlBarGraphic

Usability: Edit/Runtime	Type:  Read/Write	Values:  FileName

Example	See Also	Default: None

The custom control graphic bitmap file.  This bitmap can be created in any graphic package that outputs in a bitmap format.  It must then be accompanied by the Control Bar Data file.


ErrorCount

Usability: Runtime	Type:  Read	Values:  0+

Example	See Also	Default: 0

This is the number of errors encountered since the file was opened.  Remember, some errors can be ignored without bad side effects.  It really depends on the error and its severity.


ErrorNumber

Usability: Runtime	Type:  Read	Values:  Numeric

Example	See Also	Default: None

This property will report the latest error code recorded within the application.  If the value is zero (0), no errors have occurred.


ErrorSeverity

Usability: Runtime	Type:  Read	Values:  0-4

Example	See Also	Default: 0

Indicates how severe the last encountered error was.  It can be one of four severity levels.

1:	Failure - A Library command failed to execute.

2:	Parameter - An invalid parameter was passed to the library.

3:	Ignore - A Library command was ignored because it did not make sense to execute it.

4:	Continue - Although an error was encountered, the Library will continue to execute because it was determined that the error should not cause a problem.


FileName

Usability: Edit/Runtime	Type:  Read/Write	Values:  Various

Example	See Also 	Default: None

This property identifies the name of the AV file to be played.

The filename of the audio of video file can be entered through any one of two ways.

1:  In edit or run mode by setting the FileName property

2:  By binding the VBVideo control to a Data control


Frame

Usability: Runtime	Type:  Read	Values:  Numeric

Example	See Also	Default: None

The current frame number of the AV file.  This property will constantly be updated as the AV file is running.  Note that video frame numbers differ from that of audio only (wave) files.  Video files may have different frame per second rates while wave audio files have 1000 frames per second.  This makes calculating elapsed time within a video file more difficult that wave files.


FrameBeg

Usability: Edit/Runtime	Type:  Read/Write	Values:  Numeric

Example	See Also	Default: 0

Identifies the starting frame number.  Once the file is opened, it will be positioned at or near this frame.  If the frame number is not a key frame, the video will be positioned to the nearest key frame prior to the .

This property can be set after the file has been opened.  If the file is open and this property is set, the current frame will be repositioned.


FrameEnd

Usability: Edit/Runtime	Type:  Read/Write	Values:  Numeric

Example	See Also	Default: 0

Identifies the ending frame number.  This property identifies the frame number at which the audio/video will pause.  Unlike the FrameBeg, FrameEnd is accurate to any valid frame number.  That is, FrameEnd is not affected by non-key frames.

This property can be set after the file has been opened.  If FrameEnd is set to a number higher than the current frame, the file will not be repositioned.  If FrameEnd is set to a number lower than the current frame, the file will be repositioned to the value in FrameBeg.

Note: A value of 0 indicates that the control should play to the last frame in the file.


Length

Usability: Runtime	Type:  Read	Values:  Numeric

Example	See Also	Default: None

Length returns the total number of frames held in the file.  Video frames differ from that of audio frames.  The number of video frames per second depends directly on the frame rate of the video as well as the total time of the video.

If the video file is 2 minutes 25 seconds long, and the frame rate is 30 frames per second the length would be roughly 4350 frames.  (( 2 * 60) + 25 ) * 30)

Conversely, if the file length is 6255 frames and the frame rate is 15 frames per second the elapsed time would be roughly (6255 / 15) = 417 seconds or 6 minutes 57 seconds.


MCIReturn

Usability: Runtime	Type:  Read	Values:  Various

Example	See Also	Default: False

The MCIReturn property will contain the resulting value when using the MCIString property to make calls to MCI.


MCIString

Usability: Runtime	Type:  Write	Values:  Various

Example	See Also	Default: False

By setting this property to an MCI String command, you can control or get information from the AV file.  The VBVideo control will automatically insert the alias


MCIID

Usability: Runtime	Type:  Read	Values:  Numeric

Example	See Also	Default: None

Returns the MCI Device ID number generated when the file is opened.  This property is useful only if you wish to develop your own code utilizing the MCISendCommand function.  This function, although similar to the MCISendString, is much more complicated to use and is typically used in C/C++ to control multimedia.


PlayState

Usability: Runtime	Type:  Read	Values:  0 - 5

Example	See Also	Default: None

The PlayState can have any of the following values:

0:  Closed	The file is currently closed

1:  Playing	The file is playing

2:  Paused	The file is paused

3:  Seeking	The file is jumping to a new frame

4:  End	The file has reached the end of the clip

5:  Stopped	The file is stopped

4:  End is very useful with timing since it is a very reliable way of knowing when the AV clip has completed playing.

Stopped differs from a Paused state since Pause does not release any system resources even though it is not playing.  The Stopped state indicates that as much of the system resources as possible have been released while keeping the file open.

Some video technologies will go to black when in the stopped state.  Software only compressed files will usually keep an image on the screen even when in a stopped state.

Also, you cannot play more than one wave audio at a time.  This means that if there are more than one file with wave audio open, all but the currently playing file must be in a stopped state.

The state of the file can be controlled through the Command property.


PlayUpon

Usability: Edit/Runtime	Type:  Read/Write	Values:  0 - 1

Example	See Also	Default: 0

Indicates the point at which the Audio/Video file will play.  A value of 0 (Default) waits until the Command property is set to 3.  A value of 1 automatically plays the file directly after the file is loaded.


Repeat

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: False

A value of True will cause the AV file to jump back to the beginning and start playing when it has reached the last frame of the clip.


ShowErrors

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: True

This property controls the displaying of error messages during runtime.  If this property is set to FALSE, error messages will not be displayed when they occur.  When set to true, certain critical error messages will be displayed if and when they occur.


TimerEnabled

Usability: Edit/Runtime	Type:  Read/Write	Values:  True/False

Example	See Also	Default: False

When this property is set to True, the Timer event will fire every TimerInterval milliseconds.

When set to False, the Timer event will not occur.


TimerInterval

Usability: Edit/Runtime	Type:  Read/Write	Values:  Numeric

Example	See Also	Default: 0

The number of milliseconds between each Timer event.  This property must be used in combination with the TimerEnabled property.

If the TimerInterval is set to 0, the Timer event will not occur.


Type

Usability: Runtime	Type:  Read	Values:  0 - 4

Example	See Also	Default: None

Reading this property returns the type of the opened file.

The values correspond to the following types:

0	AVI	Video for Windows, Indeo, etc.

1	AVS	Intel Digital Video Interactive

2	WAV	Wave Audio (Uncompressed or Compressed ADPCM)

3	MPG	MPEG Video

4	MOV	Quicktime for Windows


Timer Event

Example	See Also

An event associated with the TimerEnabled and TimerInterval properties.  The Timer event passes two parameters with it.  The FrameNo and PlayState parameters report the current frame number and state of the AV file.

Parameters:

PlayState:  The play state of the file when the event fired.

The play state can be one of the following:

0:  Closed

1:  Playing

2:  Seeking

3:  Paused

4:  End of file

5:  Stopped

Frame:  The frame number when the event fired.


PlayStateEvent
PlayStateChange Event

Example	See Also

This event will fire when the play state of the AV file changes.

Parameters:

PlayState:  The play state of the file when the event fired.

The play state can be one of the following:

0:  Closed

1:  Playing

2:  Seeking

3:  Paused

4:  End of file

5:  Stopped

Frame:  The frame number when the event fired.


CustomButtonClick Event

Example	See Also

This event will fire when any button is clicked on the Control Bar.

Parameters:

ButtonNo:  The number of the button clicked.

The button numbers are as follows:

0:	No button clicked	8:	Restart

1:	Step Left	9:	Rewind

2:	Step Right	11:	Scroll Thumb

3:	Play/Pause	12:	Custom

4:	Play	21:	Jump Left

5:	Pause	22:	Jump Right

6:	Close

7:	Stop


Database Support (Bound Control)

The VBVideo Custom Control can be bound to a database field holding an audio or video filename.  When the record changes, the new filename is automatically read in and opened.  This technique gives the ability to create applications that tie multimedia to specific

Benefits:

- No hardcoded filenames

- Databases can be utilized to store references to AV files.

- The references can be located in a table that only has file names or,

- The references can be part of a table which has much more information which is also displayed on the screen

- No coding necessary to cause audio or video to load and play

This technique would be very useful for such things as:

- Voice annotation of database information

- Tying textual and numeric information to an explanatory audio or video clip.

- Automated paging of information


MediaDynamics Inc.

MediaDynamics Inc. is a multimedia consulting firm specializing in the development of medium to large scale interactive multimedia applications.  Our experience includes over seven years of working in the multimedia development and technology arena, with substantial involvement in several award winning projects.

MediaDynamics' service offering includes:

    * Custom multimedia application design and

         development using a variety of languages

         and tools

    * Integration consulting and management of

         application components, software as well

         as hardware

    * Solution prototyping

    * Developer support

    * New technology research and recommendations

Development environments include  C, Visual Basic, Authorware and Toolbook;  Multimedia technologies include Indeo Video, Video for Windows, MPEG video, Intel DVI and Wave Audio.

      Award List

1989 Silver CINDY Award

1989 CINDY Certificate

1992 Silver CINDY Award

1993 Invision Award of Excellence

1993 Invision Gold Medal

1994 Invision Award of Excellence

1994 Invision Gold Medal

1994 New York Festivals Multimedia Competition

1995 Invision Silver Medal


AutoLoad See Also

AutoSize

Command

PlayUpon


AutoSize See Also

AutoLoad


Command See Also

AutoLoad

ControlBar

MCIString

PlayState

PlayUpon


ControlBar See Also

Command

MCIString

PlayState

PlayUpon

ControlBarData

ControlBarGraphic


ErrorCode See Also

ShowErrors

ErrorCount

ErrorNumber

ErrorSeverity


FrameBeg See Also

FrameEnd

Length

Timer Event


FrameEnd See Also

FrameBeg

Length

Timer Event


 Frame See Also

FrameBeg

FrameEnd

Length

PlayState

Timer Event


FileName See Also

AutoLoad

PlayUpon

Database Support (Bound Control)


Length See Also

FrameBeg

FrameEnd

Frame

PlayState

Timer Event


MCIID See Also

MCIReturn

MCIString


MCIReturn See Also

MCIID

MCIString


MCIString See Also

Command

MCIReturn

MCIID

Frame

PlayState

PlayUpon


PlayState See Also

ControlBar

Command

Timer Event


PlayUpon See Also

AutoLoad

ControlBar

Command

MCIString


ShowErrors See Also

ErrorNumber


TimerEnabled See Also

PlayState

TimerInterval

Timer Event


TimerInterval See Also

PlayState

TimerEnabled

Timer Event


Timer Event See Also

PlayState

TimerEnabled

TimerInterval


Type See Also

Formats Supported


ScrollLeft

The Audio/Video will jump backward and redisplay.


ScrollRight

The Audio/Video will jump forward and redisplay.


ScrollThumb

This control will allow you to scroll forward and back.  Depending on the video type, the image may or may not update while the scroll is in progress.


ScrollFast

By clicking in this region the Audio/Video will jump many frames and redisplay itself.


Play/Pause

This button plays or pauses the Audio/Video depending on what state the file is currently in.


Video Display
Video Display Area

The area of the control where the video will display.  Note that this window will not appear if the file being played is wave audio only.


Frame Rate

In video files, this is the playback speed in number of frames per second.  Frame rates are usually less than 30 frames per second (fps) but can be any number.  In audio files, this number is 1000 per second.


Milliseconds

There are 1000 milliseconds per second.  Setting the interval to 500 would cause the timer to fire every 1/2 second or 2 times a second.


Alias

When an AV file is opened a shorter name is associated with it.  This makes the calling of MCI commands easier.  This alternate name is called the "alias".


MCI Media Control Interface

A standard set of commands for controlling multimedia.  Through the use of these MCI commands the VBVideo control stays compatible with various types of video and audio.


Video Clipping See Also

ClipLeft

ClipTop

ClipWidth

ClipHeight

ClipType


Visual Basic Standard Property

See the Visual Basic documentation for additional information about this property.


Video Clipping

The process of identifying a smaller rectangular viewing region within the original video image display.


AutoLoad Example

VBVideo1.AutoLoad = FALSE  ' Tell the control not to automatically load the file.

VBVideo1.FileName = "D:\Video\Video.AVI"  ' Identify the video file

:

:

'Later in the program

VBVideo1.Command = 1  ' Load the Video File


AutoSize Example

VBVideo1.AutoSize = FALSE  ' Tell the control not to automatically size the file.

VBVideo1.Visible = False ' Load but don't show the video file.

VBVideo1.FileName = "D:\Video\Video.AVI"  ' Identify the video file.

VBVideo1.Width = 160   ' Set the width of the display window.

VBVideo1.Height = 120  ' Set the height of the display window.

VBVideo1.Visible = True ' Show the video file.


Clipping Example

VBVideo.AutoSize = False   ' Shut off autosize which will interfere with clipping

VBVideo1.ClipLeft = 30

VBVideo1.ClipTop = 20

VBVideo1.ClipWidth = 160

VBVideo1.ClipHeight = 120

VBVideo1.ClipType = 1   ' Video cropped and aligned

VBVideo1.FileName  = "D:\Video\Video1.AVI"   ' Identify and open the video

The above code will display a video image 160 pixels wide by 120 pixels high that is extracted from the original video image at position 30,20.


Command Example

The examples below show two VB buttons used to pause and play the AV file.

Sub cmdPause_Click()

    VBVideo1.Command = 3  ' Pause the file

End Sub

Sub cmdPlay_Click()

    VBVideo1.Command = 2   ' Play the file

End Sub


ControlBar Example

To hide the Control Bar set the value to False.

VBVideo1.ControlBar = False  ' Hide the control bar

To make it show...

VBVideo1.ControlBar = True  ' Show the control bar


ControlBarData/Graphic Example

This example will load the graphic and information file that will display a custom control bar.

' Load the Control Bar Information File

VBVideo1.ControlBarData = "C:\CTRLBAR\CTRLBAR.MCL"

' Load the Control Bar Graphic File

VBVideo1.ControlBarGraphic = "C:\CTRLBAR\CTRLBAR.BMP"

' Load the video file

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"


Error Handling Example

VBVideo1.ShowErrors = False  ' No automatic error display

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"

If VBVideo1.ErrorNumber = 101 Then

  MsgBox "File Not Found: " & VBVideo1.FileName  ' Display own message

  nErrorCount = VBVideo1.ErrorCount

  nErrorSeverity = VBVideo1.ErrorSeverity

End If


FileName Example

1: Automatic Load

' This will automatically load and show the video

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"

2: Using "Command" to load the file

VBVideo1.AutoLoad = False

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"

'Later in the program

VBVideo1.Command = 1  ' Load the video file


Frame Example

The following example shows how the Frame property can be used within a timer.

Sub Timer1_Timer

    Label1.Caption = VBVideo1.Frame

End Sub

This example shows how the Frame property can be used to display "timed" graphics.

Sub Timer1_Timer

    Select Case VBVideo1.Frame

        Case 60 to 100  ' Use a range

            Picture1.Visible = True

        Case 120 to 240  ' Use a range

            Picture2.Visible = True

    End Select

End Sub


FrameBeg/End Example

To set a clip within a larger file:

VBVideo1.FrameBeg = 300  ' Where the video will start

VBVideo1.FrameEnd = 500  ' Where the video will end

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"  ' Load the video file


MCIString/Return Example

To call an MCI String command directly:

VBVideo1.MCIString = "Status Frames Skipped"   ' Send the Command

nFramesSkipped = VBVideo1.MCIReturn  ' Get the return value


Length Example

To get the length of a video file:

VBVideo1.FileName = "C:\VIDEO\VIDEO.AVI"   ' Load the file

nLength = VBVideo1.Length   ' Get the length


MCIID Example

To get the MCI ID number of a video file:

VBVideo1.FileName = "C:\VIDEO\VIDEO.AVI"

nMCIID = VBVideo1.MCIID  ' Get the MDI ID number


Repeat Example
Repeat/PlayUpon Example

To load a video, play it and make it repeat when it reaches the end:

VBVideo1.PlayUpon = 1  ' Play Upon Load

VBVideo1.Repeat = True  ' Set to repeat

VBVideo1.FileName = "D:\VIDEO\VIDEO.AVI"

The file will load, play and repeat.


TimerInterval/Enabled Example

To set the timer to fire an event every second:

VBVideo1.Interval = 1000

VBVideo1.TimerEnabled = True

This will cause the VBVideo timer event to fire once every second.


Type Example

To determine the type of the loaded file:

nType = VBVideo1.Type

Select Case nType

    Case 0

        ' Execute code for AVI files

    Case 1

        ' Execute code for DVI files

    Case 2

        ' Execute code for WAV files

    Case 3

        ' Execute code for MPEG files

    Case 4

        ' Execute code for Quicktime files

End Select


Timer Event Example

Sub VBVideo_Timer( PlayState as Integer, Frame as Long )

    If PlayState = 1 Then  ' If the file is actually playing

        Label1.Caption = Frame  ' Show the current frame

        Select case Frame

            Case 90 to 120  ' Use ranges with frame numbers and Timers

                Picture1.Visible = True

            Case 200 to 250

                Picture2.Visible = True

        End Select

    End If

End Sub


PlayStateChange Event Example

Sub VBVideo1_PlayStateChange( PlayState as Integer, Frame as Long )

    Select Case PlayState

        Case 1

            Label1.Caption = "Playing"

        Case 2

            Label1.Caption = "Seeking"

        Case 3

            Label1.Caption = "Paused"

        Case 4

            Label1.Caption = "Done"

        Case 5

            Label1.Caption = "Stopped"

    End Select

End Sub


PlayStateChange Event See Also

PlayState

Frame


PlayState See Also

TimerInterval

TimerEnabled

Timer Event

PlayStateChange Event


PlayState Example

Select Case VBVideo1.PlayState

    Case 1

        Label1.Caption = "Playing"

    Case 2

        Label1.Caption = "Seeking"

    Case 3

        Label1.Caption = "Paused"

    Case 4

        Label1.Caption = "Done"

    Case 5

        Label1.Caption = "Stopped"

End Select


Repeat See Also

PlayUpon

PlayState

PlayStateChange Event

TimerEnabled

TimerInterval


CustomButtonClick_Event_Example

Sub VBVideo1_CustomButtonClick (ButtonNo as Integer)

Select Case ButtonNo

Case  12 	' The custom button was clicked

MsgBox "You Clicked the Custom Button"

End Select

End Sub


CustomButtonClick See Also

PlayStateChange Event

Timer Event